<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta name="author" content="">
    <title></title>
    <% include("../inc/list_css.html"){}%>
</head>

<body>
<div class="ibox ">
    <div class="ibox-title">
        <div class="pull-left mbx navbar_title">
            <span>品牌列表 </span>
            <span class="line">/</span>
            品牌管理
        </div>
    </div>
    <div class="ibox-content">
        <div class="wrapper wrapper-content">
            <div class="row">
                <div class="col-sm-12" >
                    <div class="btn-group margin-vertical-4_0">
                        <button class="hive-btn-md-large hive-btn-primary" id="add"><i class="icon-add" aria-hidden="true"></i>&nbsp;添加资源</button>
                        <button type="button" class="hive-btn-md-large hive-btn-primary" onclick="clerCache()">刷新商户缓存</button>
                        <button type="button" class="hive-btn-md-large hive-btn-primary" onclick="clerPlateCache()">刷新超管缓存</button>
                    </div>
                    <table id="rTableEvents" data-toggle="table" data-mobile-responsive="true" data-pagination="true" data-search="true" class=" table-striped table-no-bordered fixed-table-container table-row-border-color table-hovered table-hover">
                        <thead>
                        <tr>
                            <th>分类名称</th>
                            <th>排序</th>
                            <th>level</th>
                            <th data-field="head"  data-halign="center"  data-align="center" data-width="120">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <%for(list in resourceTreeList!){%>
                        <tr level="${list.level!}">
                            <td>
                                <span style="margin-left: ${list.level * 20}px;">
                                    <%if (list.level == 1){%>
                                        <i class="am-icon-folder-o"></i>
                                    <%}else{%>
                                        <i class="am-icon-folder-open-o"></i>
                                    <%}%>
                                ${list.name}
                                </span>
                            </td>
                            <td>${list.orderList}</td>
                            <td>${list.level}</td>
                            <td>
                                <div>
                                    <div>
                                        <%if (list.children.~size > 0){%>
                                        <a disabled="disabled" href="javascript:void(0)" class="icon-delete hive_icon color_danger" data-toggle="tooltip" data-placement="top" title="删除" style="color:#999!important;"></a>

                                        <%}else{%>
                                        <a id="deleteAction" onclick="deleteCategory('${list.id}')"  href="javascript:void(0)" class="icon-delete hive_icon color_danger" data-toggle="tooltip" data-placement="top" title="删除"></a>

                                        <%}%>
                                        <a href="javascript:void(0)" class="icon-edit hive_icon color_normal" onclick="location.href='edit?id=${list.id}'" data-toggle="tooltip" data-placement="top" title="编辑"></a>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <%}%>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<% include("../inc/list_js.html"){}%>

<script>
    function clerCache() {
        $.ajax({
            url: "clerCache",
            type: 'GET',
            data:{

            },
            success: function(data) {
                if(data.state=="ok"==true){

                    layer.msg("刷新成功!");
                }else{

                    layer.msg("刷新失败!");
                }
            }
        });
    }

    function clerPlateCache() {
        $.ajax({
            url: "clerPlateCache",
            type: 'GET',
            data:{

            },
            success: function(data) {
                if(data.state=="ok"==true){

                    layer.msg("刷新成功!");
                }else{

                    layer.msg("刷新失败!");
                }
            }
        });
    }

    $('#add').on('click', function (e) {
        location.href = '/shop/resource/add';
    });


    function edit(v) {
        location.href = "edit?id="+v;
    }
    function openWindow(id,name) {
        layer.open({
            shade: [0.3,'#fff'],//0.1透明度的白色背景
            type: 2,
            title: name+'的角色资源配置',
            shadeClose: true,
            shade: 0.8,
            area: ['380px', '60%'],
            content: '/shop/role/resource?roleId='+id //iframe的url
        });
    }
</script>
<script type="text/javascript">
    // 删除
    function deleteCategory(ids) {
        parent.layer.confirm('您确定要删除吗？', {
            btn: ['是','否'] //按钮
        }, function(){
            $.ajax({
                method:"post",
                url: 'delete',
                data:"id=" + ids + "",
                dataType: "json",
                async: false,
                success: function(data) {
                    parent.layer.msg("删除成功!");
                    setTimeout(location.href='list',1000)
                }
            });
        });
    }
</script>
</body>

</html>
